<?php
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>登录界面</title>
</head>
<script type="text/javascript">
    function changing(){
        document.getElementById('checkpic').src="captcha.php?"+Math.random();
    }

    function InputCheck(LoginForm)
    {
        if (LoginForm.username.value == "")
        {
            alert("请输入用户名!");
            LoginForm.username.focus();
            return (false);
        }
        if (LoginForm.password.value == "")
        {
            alert("请输入密码!");
            LoginForm.password.focus();
            return (false);
        }
    }
</script>
<style>
    *{margin:0;padding:0;}
    h1{
        margin: 100px 0 30px 0;
        text-align: center;
        font-size: 50px;
    }
    .box{
        border: solid gray 1px;
        margin: 150px 500px 400px;
        width: 650px;
        height:450px;
        background-color: seagreen;
    }
    table{margin-left: 20px;}
    tr,input{
        font-size: 35px;
        margin: 5px;
    }
    th{float: right;}

    .button input{
        width: 200px;
        text-align: center;
        margin: 10px 200px ;
        border-radius: 10px;
    }
    .button input:hover{background:#1263be;}
    body{background: url("imag/7.jpg")};

</style>
<TABLE height=31 width=41 align=left  border=0>
    <TBODY>
    <TR>
        <TD vAlign=top align=right type="vertical" spacer>
            <FONT face=华文行楷 style="font-size:50px;padding-left: 100px" ><B>欢<BR>迎<BR>你<BR>来<BR>到<BR><BR>异<BR>乡<BR>客</B></FONT>
        </TD>
    </TR>
    </TBODY>
</TABLE>
<body>
<div class="box">
    <h1>用户登录</h1>
    <form method="post">
    <table>
            <tr>
                <th>用户名：</th>
                <td><input type="text" placeholder="请输入用户名" name="username"/></td>
            </tr>
            <tr>
                <th>密码：</th>
                <td><input type="password" placeholder="请输入密码" name="password"/></td>
            </tr>
            <tr>
                <td colspan="2" class="button">
                    <input type="submit" value="登录" />
                    <FONT face=华文行楷 color=black size=5><B>温馨提示：“请保管好随身用品，以免发生丢失。绿色网吧，注意文明，祝你玩得愉快！”
                          </B></FONT></TD></TR></TBODY>
    </TABLE>
    </form>
</div>
<?php
if (!empty($_POST)){
    $username=isset($_POST['username'])?($_POST['username']):'';
    $password=isset($_POST['password'])?($_POST['password']):'';
    $link=mysqli_connect('localhost','root','');
    if(!$link){
        die('连接数据库失败!'.mysqli_error($link));
    }
    mysqli_query($link,'set names utf8');
    mysqli_query($link,'use jfgl');
    $username=mysqli_real_escape_string($link,$username);
    $sql = "select`idadministrator`,`administrator_password`from`administrator`";
    if ($res=mysqli_query($link,$sql)){
        $row=mysqli_fetch_assoc($res);
header('Location:main_page.php');
die;
}
}
?>

</body>
</html>

